package thread;
//线程等待
public class Demo15 {
    public static void main(String[] args) throws InterruptedException {
        //主线程里创建t线程
        Thread t = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("线程t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t结束");
        });
        t.start();
        Thread.sleep(4000);

        System.out.println("main等待");
        t.join();
        System.out.println("main结束等待");
    }

}
